﻿using System;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using System.Reflection;
using System.Windows.Forms;

namespace AndyPike.Experiments.MEF
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var form = new Form1();

            var catalog = new AggregateCatalog(new ComposablePartCatalog[] 
                { 
                    new AssemblyCatalog(Assembly.GetExecutingAssembly()), 
                    new DirectoryCatalog(@"Plugins")
                });
            var container = new CompositionContainer(catalog);
            var batch = new CompositionBatch();
            batch.AddPart(form);
            container.Compose(batch);

            Application.Run(form);
        }
    }
}
